/**
 * Copyright 2008 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kiff.util.transaction;

/**
 * Transaction Interface, used to have a generic transaction implementation for the TransactionInterceptor.
 * @author Adam
 * @version $Id: Transaction.java 62 2008-10-31 04:51:50Z a.ruggles $
 * 
 * Created on Oct 9, 2008 at 11:03:34 AM 
 */
public interface Transaction {
	/**
	 * Start the transaction. 
	 */
	void begin();

	/**
	 * Commit the transaction.
	 */
	void commit();

	/**
	 * Ends the transaction.
	 */
	void end();

	/**
	 * Determine whether the current transaction has been marked for rollback.
	 * @return true if set to rollback only, otherwise false.
	 */
	boolean getRollbackOnly();

	/**
	 * Indicates whether a transaction is in progress.
	 * @return true if the transaction is in progress, otherwise false.
	 */
	boolean isActive();

	/**
	 * Roll back the current transaction.
	 */
	void rollback();

	/**
	 * Modify the transaction associated with the current thread such that the only possible outcome of the
	 * transaction is to roll back the transaction.
	 */
	void setRollbackOnly();

	/**
	 * Modify the timeout value that is associated with transactions started by the current thread with the
	 * begin method. 
	 * @param seconds The value of the timeout in seconds. If the value is zero, the transaction service restores the
	 * default value. If the value is negative a SystemException is thrown.
	 */
	void setTransactionTimeout(int seconds);
}
